<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="navbar.jsp" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title>My JSP 'new_goal.jsp' starting page</title>
	<link rel="stylesheet" type="text/css" href="styles/css/bootstrap.min.css" />
  </head>
  
  <body class="body">
    <div class="container" style="margin-top:60px;width:960px;margin-left:auto;margin-right:auto;">
	  <div class="row">
		<div class="span9">
	<form class="form-horizontal" action="goal.jspx?m=add" method="post" id="myform" >

        <fieldset>
          <legend>添加一个新目标</legend>
          <div class="control-group">
            <label class="control-label" for="input01">目标名称</label>
            <div class="controls">
              <input style="height:28px;" type="text" class="span5" id="goalName" x-webkit-speech="undefined" name="goalName" style="height:30px"/><br />
			  <span id="span1" style="color:red;"></span>
              <p class="help-block">In addition to freeform text, any HTML5 text-based input appears like so.</p>

            </div>
          </div>
          <div class="control-group">
            <label class="control-label" for="input01" >目标描述</label>
            <div class="controls">
              <textarea class="span5" rows="8" name="desc" id="desc"></textarea><br />
			  <span id="span2" style="color:red;"></span>
            </div>
          </div>

          
          <div class="form-actions">
            <button type="button" class="btn btn-primary" id="btnSubmit">保存</button>
            <button class="btn" onclick="location.back()">返回</button>
          </div>
        </fieldset>
     </form>          
          	
		</div>
		<div class="span3">

			
		</div>
	  </div>
	</div>
	
	
	
	
	<script type="text/javascript" src="styles/jquery/jquery.js"></script>
	<script type="text/javascript">
		$(document).ready(function(){
			$("#btnSubmit").click(function(){
					var goalName = $("#goalName").val();
				if(goalName.trim().length == 0){
					$("#span1").html("标题不能为空！");
					$("#goalName").focus();
					return;
				} else if(goalName.length > 10){
					$("#span1").html("目标名称长度不能大于10");
					$("#goalName").focus();
					return;										
				}
				
				
				
				
				var desc = $("#desc").val();
				if(desc.trim().length == 0){
					$("#span2").html("目标描述不能为空！");
					$("#desc").focus();
					return;
				} else if(desc.length > 800){
					$("#span2").html("目标描述长度不能大于800个字！");
					$("desc").focus();
					return;
				}
				
				
				
				$("#myform").submit();
			});
		});
	</script>
  </body>
</html>
